#!/bin/bash
dt=`date -d '1 days ago' '+%Y-%m-%d'`

# ODS到DWD层增量处理
nohup hive -hivevar etl_dt="$dt" -f /hive_ods_dwd/inc_add.sql & > /hive_ods_dwd/full_add.log
# ODS到DWD层全量处理
nohup hive -hivevar etl_dt="$dt" -f /hive_ods_dwd/full_add.sql & > /hive_ods_dwd/full_add.log
if [ $? -ne 0 ]; then
    echo "ODS-DWD 处理失败"
    exit 1
fi
# DWD到DWS层增量处理
nohup hive -hivevar etl_dt="$dt" -f /hive_dwd_dws/inc_add.sql & > /hive_dwd_dws/inc_add.log
if [ $? -ne 0 ]; then
    echo "DWD-DWS 处理失败"
    exit 1
fi
echo "处理完成"
# DWS到ADS层增量处理
nohup hive -hivevar etl_dt="$dt" -f /hive_dws_dwd/inc_add.sql & > /hive_dws_dwd/inc_add.log
if [ $? -ne 0 ]; then
    echo "DWD-DWS 处理失败"
    exit 1
fi
echo "处理完成"

---------------------------------------------------------------

HDFS ==> Oracle
arr=(khfx jyfx jghg yjgz)
for i in "${arr[@]}" --给数组定义变量
do
sqoop export \
--connect jdbc:oracle:thin:@192.168.88.149:1521/orcl \
--username scott \
--password scott \
--table "$i" \
--export-dir /ads_${i} \
--input-fields-terminated-by ',' \
--input-null-non-string \\N \
--input-null-string '\\N' \
-m 1

Hive ==> OracleSqoop导出
arr=(khfx jyfx jghg yjgz)
for i in "${arr[@]}" --给数组定义变量
do
sqoop export \
--connect jdbc:oracle:thin:@192.168.88.149:1521/orcl \
--username scott \
--password scott \
--table "$i" \
--export-dir /user/hive/warehouse/ads.db/ads_${i} \
--input-null-non-string \\N \
--input-null-string '\\N' \
-m 1

----------------------------------------------------------
crontab -e
30 0 * * * /xxx.sh


